package com.success.application.ground;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.success.application.api.YuanbaoApi;
import com.success.application.base.BaseTitleFragment;
import com.success.application.common.param.Params;
import com.success.application.ground.activity.PubFriendActivity;
import com.success.application.ground.holder.TopHolder;
import com.success.application.myapplication.R;
import com.success.application.widget.BannerImageLoader;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by wyn on 2018/3/16.
 */
public class IndexFragment extends BaseTitleFragment {

    FriendFragment mfriendFragment;
    private int REQUEST_CODE_PubFriend = 0;
    @Override
    protected int getContentLayoutId() {
        return R.layout.friend_fragment_dateil_view;
    }

    @Override
    protected int getTitleRes() {
        return R.string.index_ground;
    }

    protected int getRightIconRes() {
        return R.mipmap.jiahao;
    }

    @Override
    protected View.OnClickListener getRightIconClickListener() {
        return new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               //转到发布页面
                Intent intent = new Intent(getActivity(), PubFriendActivity.class);
                startActivityForResult(intent, REQUEST_CODE_PubFriend);
            }
        };
    }
    //获取上一个发布朋友圈活动中传过来的数据
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE_PubFriend && resultCode == 1) {
            onTabReselect();
        }
    }

    @Override
    protected void initWidget(View root) {
        super.initWidget(root);
        /*创建fragment提交到事物中*/
        mfriendFragment = new FriendFragment();
        getActivity().getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, mfriendFragment)
                .commit();

    }

    public void onTabReselect() {
        mfriendFragment.onTabReselect();
    }

}
